home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / fragment tool / streams.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  1.8 KB  |  88 lines

  1. /*
  2.     File:        Streams.h
  3.  
  4.     Contains:    Utility routines to stream data into a block of memory
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/5/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25.  
  26. #ifndef __STREAMS__
  27. #define __STREAMS__
  28.  
  29.  
  30.  
  31. #ifndef __TYPES__
  32.     #include <Types.h>
  33. #endif
  34.  
  35. #ifndef __MEMORY__
  36.     #include <Memory.h>
  37. #endif
  38.  
  39.  
  40.  
  41.  
  42.  
  43. typedef struct StreamHeader
  44. {
  45.     Size    blockSize;
  46.     Size    currentSize;
  47.     Size    cursor;
  48.     Size    maxCursor;
  49.     
  50. } tStreamHeader, *tStreamHeaderPtr;
  51.  
  52.  
  53.  
  54. typedef Ptr        tStreamRef;
  55. typedef UInt32    tStreamCursor;
  56.  
  57.  
  58.  
  59. enum
  60. {
  61.     kInvalidStreamRef    = -1,
  62.     kBoundsErr            = -2
  63. };
  64.  
  65.  
  66.  
  67. OSErr NewStream ( tStreamRef* streamRef, Size blockSize );
  68. OSErr DisposeStream ( tStreamRef streamRef );
  69. OSErr SetStreamData ( tStreamRef streamRef, Ptr dataPtr, Size dataSize );
  70. OSErr GetStreamData ( tStreamRef streamRef, Ptr dataPtr, Size dataSize );
  71. OSErr GetStreamDataPtr ( tStreamRef streamRef, Ptr* dataPtr );
  72. Size GetStreamDataSize ( tStreamRef streamRef );
  73. tStreamCursor GetStreamCursor ( tStreamRef streamRef );
  74. OSErr SetStreamCursor ( tStreamRef streamRef, tStreamCursor byteCount );
  75. void ResetStreamCursor ( tStreamRef streamRef );
  76. OSErr CompactStream ( tStreamRef streamRef );
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. #endif // define __STREAMS__
  87.  
  88.